home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Inspectors / description.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  2.6 KB  |  74 lines

  1. // Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. //form field names:
  3. //Description - text field
  4.  
  5. // *********** GLOBAL VARS *****************************
  6.  
  7. var helpDoc = MM.HELP_inspDescription;
  8.  
  9. // ******************** API ****************************
  10. function canInspectSelection(){
  11.   var dom = dw.getDocumentDOM();
  12.   var metaObj = dom.getSelectedNode();
  13.   if (!metaObj || !metaObj.getAttribute) return false;
  14.  
  15.   return (metaObj.tagName && metaObj.tagName == "META" &&
  16.           metaObj.getTranslatedAttribute("name") && 
  17.           metaObj.getTranslatedAttribute("name").toLowerCase()=="description");
  18. }
  19.  
  20. function inspectSelection(){
  21.   var dom = dw.getDocumentDOM();
  22.   var metaObj = dom.getSelectedNode();
  23.   if (!metaObj || !metaObj.getAttribute) return;
  24.   
  25.   var inspectorState = arguments[0],currKeyVal;
  26.   var description = findObject("Description");
  27.   var contentLayer = findObject("contentField");
  28.   var contentCell = contentLayer.getElementsByTagName("TD").item(0);
  29.   var minText= '<textarea name="Description" onBlur="setMetaTag()" '
  30.   + 'style="width:350;height:32" rows="2" wrap="virtual"></textarea>'
  31.   var maxText='<textarea name="Description" onBlur="setMetaTag()" '+
  32.   'style="width:350;height:76" rows="4" wrap="virtual"></textarea>';
  33.   //change inspector state if needed
  34.   //the rows=X check determines whether current state is min or max
  35.   if (inspectorState=="min"&& (findString('rows="4"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  36.     currKeyVal = description.value;
  37.     contentCell.innerHTML = minText;
  38.     // re-find the Description field (because it has just been replaced) before
  39.     // setting its value.
  40.     description = findObject("Description");
  41.     description.value = currKeyVal;
  42.   }    
  43.   else if (inspectorState=="max" && (findString('rows="2"',contentCell.innerHTML)||contentCell.innerHTML=="")){
  44.     currKeyVal = description.value; 
  45.     contentCell.innerHTML = maxText; 
  46.     // re-find the Description field (because it has just been replaced) before
  47.     // setting its value.
  48.     description = findObject("Description");
  49.     description.value = currKeyVal;
  50.   }
  51.   if (metaObj.getAttribute("content"))     
  52.     description.value = metaObj.getAttribute("content");
  53.   else
  54.     description.value="";    
  55.  
  56.   showHideTranslated();
  57. }
  58.  
  59. function findString(stringToFind,stringToLookIn){
  60.   if (stringToLookIn.indexOf(stringToFind)==-1)
  61.     return false;
  62.   return true;    
  63. }
  64.  
  65.  
  66. // ******************** LOCAL FUNCTIONS ****************************
  67.  
  68. function setMetaTag(){
  69.   dw.getDocumentDOM().getSelectedNode().setAttribute("content",findObject("Description").value);
  70. }
  71.  
  72.  
  73.  
  74.